<template>
  <div id="app">
    <div class="layout layout-has-sider" v-if="isNav">
      <div class="layout-sider sider" :style="siderStyle" :class="{'layout-hide-text':shrink}">
        <SideNav :shrink="shrink"></SideNav>
      </div>
      <TopNav @menu-toggle="toggleClick" :style="shrink ?'left:80px;transition:left .3s':'left:220px;transition:left .3s'" class="top-nav"></TopNav>
      <div class="layout layout-content" :style="shrink?'margin-left:80px':'margin-left:220px'">
        <!-- <transition :name="transitionName">  -->
          <router-view class="child-view"></router-view> 
        <!-- </transition> -->
        <GlobalFooter :links="footLinks">
          <div slot="copyright">Copyright &copy; 2017
            <strong>学创校园</strong> 团队出品</div>
        </GlobalFooter>
      </div>
    </div>
    <template v-else>
      <router-view></router-view>
    </template>
  </div>
</template>
<script>
import SideNav from '@/layouts/SideNav'
import TopNav from '@/layouts/TopNav'
import GlobalFooter from '@/components/GlobalFooter'

export default {
  components: { SideNav, TopNav, GlobalFooter },
  name: 'app',
  data() {
    return {
      shrink: false,
      siderStyle: {
        width:"220px",
      },
      transitionName: 'slide-left' ,
      // footLinks: [
      //   {
      //     title: '首页',
      //     href: '/'
      //   },
      //   {
      //     title: '文档',
      //     href: '/'
      //   },
      //   {
      //     title: 'GitLab',
      //     href: 'https://gitlab.oneitfarm.com/ladybird/ui-nuclear',
      //     blankTarget: true
      //   }
      // ]
      footLinks:[]
    }
  },
  computed: {
    //判断侧边栏和header头部是否显示，如登录界面就不展示
    isNav() {
      if (
        this.$route.name === 'user-login' ||
        this.$route.name === 'user-register' ||
        this.$route.name === 'user-result' ||
        this.$route.name === 'headercontentfooter' ||
        this.$route.name === 'headercontentsider' ||
        this.$route.name === 'headersidercontent' ||
        this.$route.name === 'siderheadercontent' ||
        this.$route.name === 'siderheadercontentretract'
      ) {
        return false
      } else {
        return true
      }
    }
  },
  methods: {
    toggleClick() {
      if (!this.shrink) {
        this.siderStyle = {
          width:"80px",
          transition:"width .3s",
        }
      } else {
        this.siderStyle = {
          width:"220px",
          transition:"width .3s",
        }
      }
      this.shrink = !this.shrink
    }
  }
}
</script>
<style lang="less">
@import 'assets/style/_settings.less';
html,
body {
  width: 100%;
  font-size:1.6*@font !important;
}

#app {
  // height: 100%;
}
.layout {
  background: @bodybg;
}

.layout.layout-has-sider {
  // height:100%;
  flex-direction: row;
  position: relative;
}

.layout-sider {
  transition: all 0.3s;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  background: #001529;
  min-width: 0;
  z-index: 10;
  box-shadow: 0 0 10px rgba(0,0,0,.8)
}
.layout-header{
  position: fixed !important;
  right:0;
  z-index:1000;
}

.layout-content {
  min-width:1000px;
  padding-top:50px;
  position: relative;;
}

.layout-content-main {
  padding: 8px;
  background: #fff;
  border-radius: 2px;
}

.layout-sider .ivu-menu-dark,
.layout-sider .ivu-menu-dark.ivu-menu-vertical .ivu-menu-opened .ivu-menu-submenu-title,
.layout-sider .ivu-menu-dark.ivu-menu-vertical .ivu-menu-item:hover,
.ivu-menu-dark.ivu-menu-vertical .ivu-menu-submenu-title:hover {
  background: #001529;
}

.layout-sider .ivu-menu-dark.ivu-menu-vertical .ivu-menu-opened {
  background: #000c17;
}

.ivu-col {
  transition: width 0.2s ease-in-out;
}

.table-operator {
  padding: 8px;
}

.inner-box {
  padding: 0 8px;
}

.form-single-col.ivu-form .ivu-form-item-label,
.form-single-col.ivu-form .ivu-radio-wrapper {
  font-size: 14px;
}

.form-single-col.ivu-form .ivu-radio-wrapper {
  margin-right: 16px;
}

.form-single-col.ivu-form .ivu-radio {
  margin-right: 8px;
}

.form-single-col .ivu-form-item-content {
  font-size: 14px;
}

.step-form {
  margin: 40px auto 0;
}

.steps {
  max-width: 750px;
  margin: 16px auto;
  overflow: hidden;
}

.steps.ivu-steps {
  display: flex;
}

.steps.ivu-steps .ivu-steps-item {
  flex: 1;
  width: auto !important;
}

.steps .ivu-steps-item:last-child {
  width: auto !important;
  flex: none;
}

.steps.ivu-steps .ivu-steps-head-inner {
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 16px;
}

.steps.ivu-steps .ivu-steps-title {
  font-size: 16px;
  line-height: 32px;
}

.steps.ivu-steps .ivu-steps-head-inner > .ivu-steps-icon.ivu-icon {
  font-size: 24px;
  line-height: 32px;
}

.no-border {
  border: none;
}

.no-border .ivu-table:after,
.no-border .ivu-table:before {
  content: none;
}

/* start login and registry*/

.container .logo {
  height: 44px;
  vertical-align: top;
  margin-right: 16px;
}

.main .tabs .ivu-tabs-nav-container {
  font-size: 16px;
  line-height: 24px;
}

.main .tabs .ivu-tabs-nav {
  float: none;
  display: inline-block;
}

.main .tabs .ivu-tabs-nav .ivu-tabs-tab {
  padding: 12px 16px;
}

.main .tabs .ivu-tabs-bar {
  text-align: center;
  border-bottom: none;
  margin-bottom: 24px;
}

.main .additional .forgot {
  float: right;
  font-size: 14px;
}

.main .additional .ivu-form-item-content {
  line-height: 22px;
}

.main .ivu-form-item-error-tip {
  font-size: 14px;
}

.main .additional .ivu-checkbox {
  margin-right: 4px;
}

.main .other {
  text-align: left;
  line-height: 22px;
  font-size: 14px;
}

.main .other .register {
  float: right;
}

.main .icon-alipay,
.main .icon-taobao,
.main .icon-weibo {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: url('https://gw.alipayobjects.com/zos/rmsportal/itDzjUnkelhQNsycranf.svg');
  margin-left: 16px;
  vertical-align: middle;
  cursor: pointer;
}

.main .icon-alipay {
  background-position: -24px 0;
}

.main .icon-alipay:hover {
  background-position: 0 0;
}

.main .icon-taobao {
  background-position: -24px -24px;
}

.main .icon-taobao:hover {
  background-position: 0 -24px;
}

.main .icon-weibo {
  background-position: -24px -48px;
}

.main .icon-weibo:hover {
  background-position: 0 -48px;
}
.tag-cloud canvas {
  transform: scale(0.25);
  transform-origin: 0 0;
}
//执行路由切换动画
.child-view { 
  width: 100%; 
  height: 100%; 
  transition: all .6s cubic-bezier(.55,0,.1,1); 
} 
.slide-left-enter, .slide-right-leave-active { 
  opacity: 0;
  transform: translate(30px, 0); 
  transition: transform 1s;
} 
.slide-left-leave-active, .slide-right-enter { 
  opacity: 0; 
  transform: translate(-30px, 0); 
  transition: transform 1s;
}
</style>
